package com.basic.business.prodRel.controller;


import java.util.List;
import java.io.IOException;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import com.basic.common.annotation.FileExport;
import com.basic.common.utils.easyExcel.EasyExcelUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.basic.common.annotation.Log;
import com.basic.common.core.controller.BaseController;
import com.basic.common.core.domain.AjaxResult;
import com.basic.common.enums.BusinessType;
import com.basic.business.prodRel.domain.TProdRelDetails;
import com.basic.business.prodRel.service.ITProdRelDetailsService;
import com.basic.common.core.page.TableDataInfo;

/**
 * 业务-商品关系明细Controller
 *
 * @author zhaoxy_jn@163.com
 */
@RestController
@RequestMapping("/business/prodDetails")
public class TProdRelDetailsController extends BaseController
{
    @Resource
    private ITProdRelDetailsService tProdRelDetailsService;

    /**
     * 根据主表ID查询商品关系明细
     */
    @GetMapping("/getProdDetailsByMainId/{mainId}")
    public TableDataInfo getProdDetailsByMainId(@PathVariable("mainId") String mainId)
    {
        List<TProdRelDetails> list = tProdRelDetailsService.getProdDetailsByMainId(mainId);
        return getDataTable(list);
    }



    /**
     * 查询业务-商品关系明细列表
     */
    @PreAuthorize("@ss.hasPermi('business:prodDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProdRelDetails tProdRelDetails)
    {
        startPage();
        List<TProdRelDetails> list = tProdRelDetailsService.getList(tProdRelDetails);
        return getDataTable(list);
    }

    /**
     * 导出业务-商品关系明细列表
     */
    @PreAuthorize("@ss.hasPermi('business:prodDetails:export')")
    @Log(title = "业务-商品关系明细", businessType = BusinessType.EXPORT)
    @FileExport(fileName = "业务-商品关系明细.xlsx")
    @PostMapping("/export")
    public String export(TProdRelDetails tProdRelDetails) throws IOException
    {
        List<TProdRelDetails> list = tProdRelDetailsService.getList(tProdRelDetails);
        return EasyExcelUtils.excelExport(TProdRelDetails.class,"业务-商品关系明细数据", list);
    }

    /**
     * 获取业务-商品关系明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:prodDetails:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tProdRelDetailsService.get(id));
    }

    /**
     * 新增业务-商品关系明细
     */
    @PreAuthorize("@ss.hasPermi('business:prodDetails:add')")
    @Log(title = "业务-商品关系明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProdRelDetails tProdRelDetails)
    {
        return toAjax(tProdRelDetailsService.insert(tProdRelDetails));
    }

    /**
     * 修改业务-商品关系明细
     */
    @PreAuthorize("@ss.hasPermi('business:prodDetails:edit')")
    @Log(title = "业务-商品关系明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProdRelDetails tProdRelDetails)
    {
        return toAjax(tProdRelDetailsService.update(tProdRelDetails));
    }

    /**
     * 删除业务-商品关系明细
     */
    @PreAuthorize("@ss.hasPermi('business:prodDetails:remove')")
    @Log(title = "业务-商品关系明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tProdRelDetailsService.deleteByIds(ids));
    }
}
